package com.serivceImpl;

import com.javabean.Role;
import com.javabean.RolePermission;
import com.mapper.RoleMapper;
import com.service.RoleService;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    RoleMapper roleMapper;

    @Override
    public List<Role> findAll() {
        return roleMapper.selectRole();
    }

    @Override
    public void add(Role role) {
        roleMapper.insertUsers(role);
    }

    @Override
    public void delete(int id) {
        roleMapper.deleteById(id);
    }

    @Override
    public Role show(int id) {
        return roleMapper.selectR_P(id);
    }

    @Override
    public void edit(Role role) {
        roleMapper.updateById(role);
    }

    @Override
    public void permissionAdd(RolePermission rolePermission) {
        roleMapper.deleteByRid(rolePermission.getRid());
        roleMapper.insertR_P(rolePermission);
    }


}
